package com.bainuo.doctor.common.widget.viewloader;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by faraway on 14/2/17.
 */
public class MyItemLoader {


    public MyItemView[] itemViews;
    //        public int itemCount;
//        public ViewGroup rootView;
    public int[] leftStringId;
    public int[] leftImgId;
    public boolean nextImage;

//        private Context context;
//        private View.OnClickListener listener;


    public void loadItems(Context context, ViewGroup rootView, int itemCount, View.OnClickListener listener) {

        itemViews = new MyItemView[itemCount];

        //加载item
        for (int i = 0; i < itemCount; i++) {

            MyItemView itemView = new MyItemView(context);

            if (leftStringId != null && leftStringId[i] != 0)
                itemView.setLeftText(context.getString(leftStringId[i]));
            else
                itemView.setLeftText("");


            if (leftImgId != null)
                itemView.setLeftImage(leftImgId[i]);

            if (nextImage)
                itemView.setNext(true);


            rootView.addView(itemView);

            itemView.setId(i);
            itemView.setOnClickListener(listener);
            itemViews[i] = itemView;
        }
    }
}
